
<!-- function for generating 2-column table based on contents of "newsletters" folder 
Added by: Tyler
3/12/08

Based on code supplied to php.net by ianatvirante.com 
http://us3.php.net/manual/en/function.readdir.php
-->
<?php
    
    // This function walks through directory specified by "$dir_handle" and creates a table 
    // with downloadable files and upload dates for all files in the directory.
    // "$path" is download path for each file.
    function list_dir($dir_handle,$path)
    {    
        echo "<table><tr><th>Newsletter</th><th>Upload Date</th></tr>";
        
        //running the while loop
        while (false !== ($file = readdir($dir_handle))) {
            $dir =$path.'/'.$file;
            
            $lastModTime = date("n\-j\-y", filectime("$path$file")); //get the date the file was uploaded
            
            if($file != '.' && $file !='..' && !is_dir($file))            // updated by Archana, 3.17.09 
            {
                 echo "<tr><td><a href='ftp:".$path.$file."' target='_blank'>".$file."</a></td><td>".$lastModTime."</td></tr>";
            }
        }
       
        echo "</table>";
    
        //closing the directory
        closedir($dir_handle);
       
    }
?> 

        
            
<div id="newsletter_archive">
<h3>Newsletter Archive</h3>

<!-- generates 2-column table for archived newsletters -->
<?php
     //define the path as relative
    $path = "newsletters/";
    
    //using the opendir function
    $dir_handle = @opendir($path) or die("Unable to open $path");
    
    list_dir($dir_handle,$path);
?>
        
</div>
           
